package com.pospi.pospihold.ui.cash_ui;

import android.app.DatePickerDialog;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.TextView;

import com.pospi.pospihold.R;
import com.pospi.pospihold.ui.base.BaseActivity;

import java.util.Calendar;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class OpenShopActivity extends BaseActivity {

    @Bind(R.id.iv_last)
    ImageView ivLast;
    @Bind(R.id.tv_data)
    TextView tvData;
    @Bind(R.id.iv_next)
    ImageView ivNext;
    @Bind(R.id.tv_response_person)
    TextView tvResponsePerson;
    @Bind(R.id.tv_last_settle)
    TextView tvLastSettle;
    @Bind(R.id.tv_sys_time)
    TextView tvSysTime;
    @Bind(R.id.btn_sure)
    TextView btnSure;

    private final Calendar c = Calendar.getInstance();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentLayout(R.layout.activity_open_shop);
        setTitle("开店");
        ButterKnife.bind(this);

        c.get(c.DATE);
        tvSysTime.setText(DateFormat.format("yyyy-MM-dd", c));
        tvData.setText(DateFormat.format("yyyy-MM-dd", c));
    }

    @OnClick({R.id.iv_last, R.id.tv_data, R.id.iv_next, R.id.btn_sure})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_last:
                c.add(c.DATE, -1);//
                tvData.setText(DateFormat.format("yyyy-MM-dd", c));
                break;
            case R.id.tv_data:
                DatePickerDialog dialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                        c.set(year, monthOfYear, dayOfMonth);
                        tvData.setText(DateFormat.format("yyyy-MM-dd", c));
                    }
                }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
                dialog.show();
                break;
            case R.id.iv_next:
                c.add(c.DATE, 1);//
                tvData.setText(DateFormat.format("yyyy-MM-dd", c));
                break;
            case R.id.btn_sure:
                break;
        }
    }
}
